<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//分类表
class Content_model extends CI_Model{
    function __construct() {
        parent::__construct();
        $this->table = 'content';
        $this->report_status = 'content_report_status';
    }
    
    function get($where){
        return $this->db->select('*')->from($this->table)->where($where)->order_by('create_time desc')->get()->row_array();
    }
    
    function get_list($where,$page,$limit){
        return $this->db->select('*')->from($this->table)->where($where)->order_by('create_time desc')->limit($limit, $page)->get()->result_array();
    }
    function getList($where){
        return $this->db->select('*')->from($this->table)->where($where)->order_by('create_time desc')->get()->result_array();
    }
    
    function get_count($where){
        $this->db->select('*');
        $this->db->from($this->table);
        $this->db->where($where);
        $this->db->order_by('create_time','desc');
        $query = $this->db->get();
        return $query->num_rows();
    }
    
    function get_report_list($where,$page,$limit){
        $this->db->select($this->table.'.*,'.$this->report_status.".is_see,".$this->report_status.".is_del");
        $this->db->from($this->table);
        $this->db->join($this->report_status,$this->table.".id = ".$this->report_status.".report_id and tan_content_report_status.user_id = ".$this->user_info['user_id'],"left");
        $this->db->where($where);
        $this->db->order_by('create_time desc');
        $this->db->limit($limit, $page);
        return $this->db->get()->result_array();
    }
    
    function update($data,$uid){
       return $this->db->where('id',$uid)->update($this->table, $data);
    }
    
    function insert_all($data){
        return $this->db->insert_batch($this->report_status,$data);
    }
    
}
